package prototech.ahedra.form;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;
import org.apache.struts.upload.FormFile;

public class UploadForm extends ActionForm {
	private FormFile file;

	public FormFile getFile() {
		return file;
	}

	public void setFile(FormFile file) {
		this.file = file;
	}

	@Override
	public void reset(ActionMapping mapping, HttpServletRequest request) {
		// TODO Auto-generated method stub
		file = null;
	}

	@Override
	public ActionErrors validate(ActionMapping mapping,
			HttpServletRequest request) {
		// TODO Auto-generated method stub
		ActionErrors errors = new ActionErrors();
//		if (file.getFileSize() == 0) {
//			errors.add("file", new ActionMessage("upload.file.required"));
//		} else if (!file.getContentType().equals("application/vnd.ms-excel")) {
//			errors.add("file", new ActionMessage("upload.file.xlsRequired"));
//		}
		return errors;
	}

}
